﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using System.Xml;

namespace IYAKASAPortal.LabourVerify
{
    public partial class VehicleDDResult : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
             
            if(Request["JCLSH"]!= null && !string.IsNullOrEmpty(Request["JCLSH"]))
            {
                string LWLSH = Request["JCLSH"];
                NET_AJ_JK_RESULT_BLL bll = new NET_AJ_JK_RESULT_BLL();
                NET_AJ_JK_RESULT[] arr = bll.GetModelList("LWLSH = '" + LWLSH+"'");
                List<RevcInfo> list = new List<RevcInfo>();
                foreach (var item in arr)
                {
                    RevcInfo info = new RevcInfo();

                   // XmlDocument xmlDoc = new XmlDocument();
                   // xmlDoc.LoadXml(item.RevcInfo);
                   // XmlNode root = xmlDoc.SelectSingleNode("root");
                   // XmlNode head = root.SelectSingleNode("head");
                    
                   //info.Msg  = head.SelectSingleNode("message").InnerText;
                   info.JKType = item.JKName;
                   info.Suc = item.IsSuc;
                   info.RowId = item.ID;
                   info.DateStr = ((DateTime)item.LogTime).ToString("yyyy-MM-dd HH:mm:ss");


                   list.Add(info);
                }

                RevcInfoWithNum infoWithNum = new RevcInfoWithNum();
                infoWithNum.Num = Request["JCLSH"].ToString();
                infoWithNum.DataInfo = list;

                string str = JsonConvert.SerializeObject(infoWithNum);
                Response.Write(str);
                
                
            }
          
            Response.End();
        }
    }

    public class RevcInfo
    {
        public string Msg
        {
            get;
            set;
        }

        public string JKType
        {
            get;
            set;
        }

        public string Suc
        {
            get;
            set;
        }
        public int RowId
        {
            get;
            set;
        }

        public string DateStr
        {
            get;
            set;
        }
    }

    public class RevcInfoWithNum
    {
        public string Num
        {
            get;
            set;
        }
        public List<RevcInfo> DataInfo
        {
            get;
            set;
        }
    }
}